#include "custom_widget.h"
#include "common_ui.h"
#include "global_variable.h"

CustomWidget::CustomWidget(QWidget *parent, bool isSubWindow) :
    kdk::KWidget(parent),
    m_isSubWindow(isSubWindow),
    m_parentWindow(parent)
{
    if (m_parentWindow != nullptr && m_isSubWindow == false) {
        m_isSubWindow = true;
    }

    if (m_isSubWindow == true) {
        setWindowFlags(Qt::Tool);
        setWindowModality(Qt::ApplicationModal);
    }
    setIcon(APP_ICON_NAME);
}

CustomWidget::~CustomWidget()
{
}

void CustomWidget::show()
{
    if (m_isSubWindow == true && m_parentWindow != nullptr) {
        centerTheWindow(this, m_parentWindow);
    }
    QWidget::show();
}